package com.hairy.nipples.hardware.accelerometer;

import static android.content.Context.SENSOR_SERVICE;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;

public class PhoneMovementDetector {
	public static void delegateActions(final Context context,
			PhoneMovementBasedActionsCallback callback) {
		final SensorManager sensorManager = (SensorManager) context
				.getSystemService(SENSOR_SERVICE);
		final Sensor accelerometer = sensorManager
				.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

		final AccelerometerListener accelerometerListener = new AccelerometerListener(
				callback, sensorManager);

		sensorManager.registerListener(accelerometerListener, accelerometer,
				SensorManager.SENSOR_DELAY_FASTEST);
	}

	public static interface PhoneMovementBasedActionsCallback {
		void doActionsWhenMoving();

		void doActionsWhenStill();
	}
}
